Skip to content

fix(workflow-persistence): make persistMigratedBlocks' updated_at guard millisecond-tolerant#5790

Merged
icecrasher321 merged 3 commits into
stagingfrom
fix/migrate-canonical
Jul 21, 2026
Merged

fix(workflow-persistence): make persistMigratedBlocks' updated_at guard millisecond-tolerant#5790
icecrasher321 merged 3 commits into
stagingfrom
fix/migrate-canonical

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

Drizzle truncates Postgres microsecond timestamps on read, so the strict equality never matched, block migrations (e.g. canonicalModes backfill) silently never persisted, and workflows showed a permanently stuck "Update" deploy state

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Jul 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 21, 2026 7:43pm

Request Review

@cursor

cursor Bot commented Jul 21, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches deploy change detection, collaborative sync, socket join rehydration, and DB optimistic-concurrency guards—core editor correctness paths with broad test coverage but meaningful regression surface if guards are wrong.

Overview
Fixes stuck deploy "Update" and related draft/sync bugs by making Postgres timestamp handling exact, tightening how local state is merged and compared, and centralizing HTTP draft sync on socket join.

Persistence: persistMigratedBlocks and block loads now compare updated_at via captured ::text microsecond values and ::timestamp casts instead of JS Date equality, so load-time block migrations actually persist. Background-work list pagination uses the same pattern for keyset cursors, with validation so bad cursors fall back to page one.

Draft sync: syncLocalDraftFromServer moves to @/stores/workflows/sync-local-draft, fetches migrated state through the shared React Query key, and retries when remote collaborator edits land mid-fetch. Socket workflow-state prefers that HTTP path and only applies raw realtime payload as a guarded fallback.

Deploy / merge / compare: Subblock merge treats explicit null as cleared (no fallback to stale structure values). Workflow comparison sanitizes table subblocks (ignore row ids and blank starter rows). Collaborative handlers bump remoteApplyVersions so sync does not clobber in-flight remote edits; per-frame position updates no longer count as applied remote changes.

Reviewed by Cursor Bugbot for commit d4c96d1. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR improves workflow persistence and client-state synchronization. The main changes are:

  • Preserves PostgreSQL timestamp precision for migration guards and pagination cursors.
  • Centralizes local draft synchronization and protects join-time hydration from newer edits.
  • Aligns workflow and subblock stores around explicit clears and live values.
  • Normalizes table subblocks to avoid false deployment-change indicators.
  • Adds tests for synchronization, cursor precision, comparison, and merge behavior.

Confidence Score: 5/5

The latest changes look safe to merge.

  • No additional blocking issue qualifies for this follow-up review.
  • The timestamp query and import changes match existing repository patterns.

Important Files Changed

Filename Overview
packages/workflow-persistence/src/load.ts Uses full-precision PostgreSQL timestamp text for guarded migration persistence.
apps/sim/app/workspace/providers/socket-provider.tsx Fetches migrated workflow state during joins and guards the raw-state fallback against newer changes.
apps/sim/stores/workflows/sync-local-draft.ts Centralizes server snapshot synchronization with local and remote version checks.
apps/sim/lib/workflows/comparison/normalize.ts Normalizes table rows to ignore generated identifiers and blank presentation rows.
apps/sim/ee/workspace-forking/lib/background-work/store.ts Preserves microsecond precision across background-work pagination cursors.

Reviews (2): Last reviewed commit: "improvement(sockets): state improvements" | Re-trigger Greptile

Comment thread packages/workflow-persistence/src/load.ts Outdated
@icecrasher321
icecrasher321 requested a review from a team as a code owner July 21, 2026 19:29
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

bugbot run

Comment thread apps/sim/app/workspace/providers/socket-provider.tsx Outdated
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit d4c96d1. Configure here.

@icecrasher321
icecrasher321 merged commit 37628f1 into staging Jul 21, 2026
31 of 33 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/migrate-canonical branch July 22, 2026 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant